<?php

/**
 * Class TaxonomyCreateAction
 */
class TaxonomyCreateAction extends CAction
{
	public $view = 'create';

	public $bundle;

	public function run()
	{
		$model = new Taxonomy();
		$model->bundle = $this->bundle;

		if (isset($_POST['Taxonomy'])) {
			$model->attributes = $_POST['Taxonomy'];

			if ($model->save()) {
				Yii::app()->getUser()->setFlash('success', '分类创建成功');
				if (isset($_POST['_addanother'])) {
					$url = array('create');
				} elseif (isset($_POST['_continue'])) {
					$url = array('update', 'id' => $model->id);
				} else {
					$url = array('view', 'id' => $model->id);
				}
				$this->getController()->redirect($url);
			}
		}

		$this->getController()->render($this->view, array('model' => $model));
	}
} 